#!/usr/bin/env node

const http = require('http'),
      url = require('url'),
      msg = process.argv[2];
//msg是向服务器程序发送的特定数据
const addr = 'http://localhost:3000';
const opt = url.parse(addr);
opt.method = 'post';

const req = http.request(opt,(res) => {
  console.log(`响应起始行：HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  console.log(res.headers);
  console.log();
  console.log(res.pipe(process.stdout))
  res.pipe(process.stdout);
})
req.end(msg); 
